<template>
	<view>
		<view class="page">
			<comp-common v-bind="{data:data}" @getUserInfo="getUserInfo" @myLogin="myLogin" @getPhoneNumber="getPhoneNumber" @hideGetCoupon="hideGetCoupon" @closeCouponBox="closeCouponBox" @navigatorClick="navigatorClick"></comp-common>
			<comp-header v-bind="{data:data}" @relevanceError="relevanceError" @relevanceSuccess="relevanceSuccess"></comp-header>
			<view class="body after-navber" v-if="data.store_list">
				<view :class="[data.show_card?'no-scroll':'',data.show_shop||data.show_coupon_picker||data.show_card?'hidden':'']" style="padding-bottom: 129upx;">
            <view class="block" v-if="data.store_offline">
                <view @tap="goToAddress" class="address-picker flex-row" hoverClass="none">
                    <view class="flex-grow-1" v-if="data.address">
                        <view class="flex-row" style="margin-bottom: 20upx">
                            <view class="flex-grow-1">收货人：{{data.address.name}}</view>
                            <view class="flex-grow-0">{{data.address.mobile}}</view>
                        </view>
                        <view style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis">收货地址：{{data.address.province}}{{data.address.city}}{{data.address.district}}{{data.address.detail}}</view>
                    </view>
                    <view class="flex-grow-1" v-else>
                        <view style="color:#ff4544">请选择收货地址</view>
                    </view>
                    <view class="flex-grow-0 flex-y-center">
                        <image :src="data.__wxapp_img.dapp.jiantou_r.url" style="width: 12upx; height: 22upx;margin-left: 24upx"></image>
                    </view>
                </view>
                <view class="address-bg-img flex-row">
                    <image :src="data.__wxapp_img.pt.address_top.url"></image>
                </view>
            </view>
            <view @tap="showPayment" class="flex-row flex-y-center" style="background: #fff;padding: 0 24upx;height: 90upx;margin-bottom: 20upx;">
                <view class="flex-grow-1">支付方式</view>
                <view class="flex-grow-0" v-if="data.payment==0">线上支付</view>
                <view class="flex-grow-0" v-if="data.payment==2">货到付款</view>
                <view class="flex-grow-0" v-if="data.payment==3">账户余额支付</view>
                <view class="flex-grow-0">
                    <image :src="data.__wxapp_img.dapp.jiantou_r.url" style="width: 12upx;height: 22upx;margin-left: 12upx"></image>
                </view>
            </view>
            <view class="store-item" v-for="(item,index) in data.store_list" :key="item.id">
                <view class="store-header">{{item.name}}</view>
                <view class="cart-list">
                    <view class="flex-col " v-if="item.show||i<1" v-for="(goods,i) in item.goods_list"  :key="goods.id">
                        <view class="cart-item border-bottom">
                            <view class="flex-row">
                                <view class="flex-grow-0">
                                    <image class="goods-pic" mode="aspectFill" :src="goods.goods_pic"></image>
                                </view>
                                <view class="flex-grow-1 flex-col">
                                    <view class="flex-grow-1">
                                        <view class="goods-name">{{goods.goods_name}}</view>
                                        <view class="attr-list">
                                            <view class="attr-item" v-for="(attr,ii) in goods.attr_list" :key="attr.id">
                                                        {{attr.attr_group_name}}:{{attr.attr_name}}
                                                    </view>
                                        </view>
                                    </view>
                                    <view class="flex-grow-0 flex-row">
                                        <view class="flex-grow-1 num">×{{goods.num}}</view>
                                        <view class="flex-grow-0 price" style="text-decoration:line-through" v-if="goods.is_level==1">￥:{{goods.price}}</view>
                                        <view class="flex-grow-0 price" v-else>￥:{{goods.price}}</view>
                                    </view>
                                </view>
                            </view>
                            <view style="color:#ff4544;text-align:right;margin-bottom:22upx;" v-if="goods.is_level==1">会员折扣价：￥{{goods.level_price}}</view>
                        </view>
                        <view class="goods-intrgral flex-row" v-if="goods.give>0">
                            <view class="flex-y-center"> 订单完成赠送</view>
                            <view class="flex-y-center" style="color:#ff4544">{{goods.give}}</view>
                            <view class="flex-y-center">积分</view>
                        </view>
                    </view>
                    <view @tap="showMore" class="show-more flex-x-center" :data-index="index" v-if="item.goods_list.length>1">
                        <view class="flex-row flex-y-center" v-if="item.show">
                            <view class="flex-grow-0">点击收起</view>
                            <image class="show-more-img flex-grow-0" :src="data.__wxapp_img.shop.down.url" style="transform:rotate(180deg);"></image>
                        </view>
                        <view class="flex-row flex-y-center" v-else>
                            <view class="flex-grow-0">展开另外
                                        <text style="color:#ff4544;">{{item.show_length}}</text>
                            </view>
                            <image class="show-more-img flex-grow-0" :src="data.__wxapp_img.shop.down.url"></image>
                        </view>
                    </view>
                </view>
                <view style="margin-bottom:20upx;">
                    <block v-if="item.store_id==0">
                        <view class="flex flex-row flex-y-center" style="background-color:#fff;padding:0 24upx;height:104upx;" v-if="item.send_type==0">
                            <view class="flex-grow-1">配送方式</view>
                            <view class="flex-grow-0 flex-row">
                                <view @tap="getOffline" :class="['flex-y-center flex-x-center send-type', item.offline==0?'active':'']" :data-index="index" data-offline="0">
                                    <view>快递配送</view>
                                </view>
                                <view @tap="getOffline" :class="['flex-y-center flex-x-center send-type', item.offline==1?'active':'']" :data-index="index" data-offline="1">
                                    <view>到店自提</view>
                                </view>
                            </view>
                        </view>
                    </block>
                    <view class="flex flex-row flex-y-center" style="background-color:#fff;padding:0 24upx;height:104upx;" v-else>
                        <view class="flex-grow-1">配送方式</view>
                        <view class="flex-grow-0 flex-row">
                            <view class="flex-y-center flex-x-center" :data-index="index" data-offline="0">
                                <view>快递配送</view>
                            </view>
                        </view>
                    </view>
                    <view class="block" v-if="item.offline==1">
                        <view class="flex-row flex-y-center border-bottom" style="padding: 0 24upx;height: 100upx;">
                            <view class="flex-grow-1" style="padding-left: 8upx;border-right:2upx solid #e3e3e3;">
                                <input @input="KeyName" :data-index="index" placeholder="请输入联系人" style="width: 300upx" :value="item.offline_name"></input>
                            </view>
                            <view class="flex-grow-1" style="margin-left:32upx;">
                                <input @input="KeyMobile" :data-index="index" placeholder="请输入联系电话" style="width: 300upx;" :value="item.offline_mobile"></input>
                            </view>
                        </view>
                        <view :@tap="item.shop_list.length>1?'showShop':''" class="flex-row border-bottom" :data-index="index" style="background: #fff;padding: 24upx">
                            <view class="flex-grow-0" style="width:160upx;">
                                <view>门店信息</view>
                            </view>
                            <view class="flex-grow-1" style="text-align:right">
                                <view>{{item.shop.name}}</view>
                                <view>{{item.shop.mobile}}</view>
                                <view>{{item.shop.address}}</view>
                            </view>
                            <view class="flex-grow-0 flex-y-center" v-if="item.shop_list.length>1">
                                <image :src="data.__wxapp_img.dapp.jiantou_r.url" style="width: 12upx;height: 22upx;margin-left: 20upx"></image>
                            </view>
                        </view>
                    </view>
                </view>
                <view style="margin-bottom:20upx;">
                    <view @tap="showCouponPicker" class="flex-row flex-y-center border-bottom" :data-index="index" style="background: #fff;padding: 0 24upx;height: 90upx;" v-if="item.coupon_list&&item.coupon_list.length>0">
                        <view class="flex-grow-1">优惠券</view>
                        <view class="flex-grow-0">
                            <view style="color: #888" v-if="!item.coupon_list||item.coupon_list.length==0">目前无可用优惠券</view>
                            <block v-else>
                                <view style="color: #ff4544" v-if="item.picker_coupon&&item.picker_coupon.sub_price>0">-{{item.picker_coupon.sub_price}}元</view>
                                <view style="color: #ff4544" v-else>有{{item.coupon_list.length}}张优惠券可以使用</view>
                            </block>
                        </view>
                        <view class="flex-grow-0">
                            <image :src="data.__wxapp_img.dapp.jiantou_r.url" style="width: 12upx;height: 22upx;margin-left: 12upx"></image>
                        </view>
                    </view>
                    <view class="flex-row flex-y-center border-bottom" style="background: #fff;padding: 0 24upx;height: 90upx;" v-if="item.integral&&item.integral.forehead_integral>0&&data.integral&&data.integral.forehead_integral>0">
                        <view class="flex-grow-1 flex-y-center">
                            <view class="flex-y-center">使用{{data.integral.forehead_integral}}积分抵扣</view>
                            <view class="flex-y-center" style="color:#ff4544">{{data.integral.forehead}}</view>
                            <view class="flex-y-center">元</view>
                            <view @tap="integration" class="flex-y-center">
                                <image :src="data.__wxapp_img.dapp.ntegration.url" style="width: 36upx;height: 36upx;margin-left: 12upx"></image>
                            </view>
                        </view>
                        <view class="flex-grow-0 flex-y-center integral-switch" :data-index="data.integral_radio">
                            <switch checked @change="integralSwitchChange" class="flex-y-center" style="height:44upx"></switch>
                        </view>
                    </view>
                </view>
                <view class="flex-row flex-y-center border-bottom" style="background: #fff;padding: 0 24upx;height: 90upx;margin-bottom:20upx;">
                    <view class="flex-grow-1">运费</view>
                    <view class="flex-grow-0">
                        <block v-if="item.offline==0">
                            <view style="color:#ff4544" v-if="data.address">￥{{item.express_price}}</view>
                            <view style="color:#888" v-else>请先选择收货地址</view>
                        </block>
                        <view style="color:#ff4544" v-else-if="item.offline==1">￥0</view>
                    </view>
                </view>
                <view class="flex flex-row flex-y-center border-bottom" style="background: #fff;padding: 0 24upx;height: 90upx" v-if="item.form.is_form==0&&item.store_id==0||item.store_id>0">
                    <view class="flex-grow-0">买家留言</view>
                    <view class="flex-grow-0" style="padding-left: 24upx">
                        <input @input="bindContentInput" :data-index="index" name="content" placeholder="请填写备注" style="width:100%;" :value="item.content"></input>
                    </view>
                </view>
                <block v-if="item.store_id==0&&item.form&&item.form.is_form==1&&item.form.list.length>0">
										<order-submit-form v-bind="{item:item,index:index,__wxapp_img:data.__wxapp_img}" @formInput="formInput" @selectForm="selectForm" @uploadImg="uploadImg"></order-submit-form>
                </block>
            </view>
        </view>
        <view class="coupon-picker" v-if="data.show_coupon_picker">
            <scroll-view class="coupon-list" scrollY="true" style="height: 100%">
                <view style="color: #888;font-size: 9pt;margin-bottom: 20upx;line-height: 1.35">
                    注：优惠券只能抵消商品金额，不能抵消运费，商品金额最多优惠到0.01元
                </view>
                <view @tap="pickCoupon" class="flex-y-center flex-x-center" data-index="-1" style="height: 80upx;margin-bottom: 24upx;color: #fff;background:#FF6C64;border: 1upx solid #FF6C64;border-radius: 10upx">不使用优惠券
                </view>
                <view @tap="pickCoupon" :class="['coupon-item', 'coupon-status-'+item.status, data.picker_coupon&&item.user_coupon_id==data.picker_coupon.user_coupon_id?'active':'']" :data-index="index" v-for="(item,index) in data.coupon_list" :key="item.id">
                    <image class="coupon-bg" :src="'/static/images/img-coupon-bg-'+(item.status==0?0:1)+'.png'"></image>
                    <image class="coupon-status-icon" :src="'/static/images/img-coupon-status-icon-'+item.status+'.png'" v-if="item.status!=0"></image>
                    <view class="flex-row" style="height: 100%;overflow: hidden">
                        <view class="flex-grow-0 flex-col flex-y-center flex-x-center coupon-left">
                            <view class="flex-row flex-y-bottom">
                                <view style="font-size: 9pt">￥</view>
                                <view :style="{fontSize: item.sub_price.length>4?'13':'19'+'pt',lineHeight: '.9'}">
                                    {{item.sub_price}}
                                </view>
                            </view>
                            <view style="font-size: 8pt;margin-top: 10upx">{{item.min_price_desc}}</view>
                        </view>
                        <view class="flex-grow-1 flex-y-center coupon-right">
                            <view style="width: 100%">
                                <view class="flex-row flex-y-center mb-10">
                                    <view class="flex-grow-1" style="font-size: 13pt;font-weight: bold">{{item.event_desc}}
                                    </view>
                                    <view class="flex-grow-0" style="font-size: 9pt"></view>
                                </view>
                                <view style="font-size: 8pt;color: #888">{{item.begin_time}} ~ {{item.end_time}}</view>
                            </view>
                        </view>
                    </view>
                </view>
            </scroll-view>
        </view>
        <view class="coupon-picker" style="background-color:#f7f7f7;" v-if="data.show_shop">
            <scroll-view class="coupon-list" scrollY="true" style="height: 100%;padding:0;">
                <view class="shop-block flex-y-center">当前地址</view>
                <view class="shop-address flex-row flex-y-center">
                    <view class="flex-grow-1">{{data.location}}</view>
                    <view @tap="dingwei" class="flex-grow-0 flex-y-center">
                        <image :src="data.__wxapp_img.shop.dingwei.url" style="width:32upx;height:32upx;margin-right:2upx;"></image>
                        <text style="color:#2495ff">手动定位</text>
                    </view>
                </view>
                <view class="shop-block flex-y-center">门店列表（仅展示您最近的30家门店）</view>
                <view @tap="pickShop" class="flex-row address-picker" :data-index="index" style="margin:0;" v-for="(item,index) in data.shop_list" :key="item.id">
                    <view class="flex-grow-0 flex-y-center">
                        <image lazyLoad="true" mode="aspectFit" :src="item.id==shop.id?'/static/images/icon-shop-checked.png':'/static/images/icon-shop-un.png'" style="width: 40upx;height: 40upx;margin-right: 20upx"></image>
                    </view>
                    <view class="flex-grow-1">
                        <view class="flex-row" style="margin-bottom: 20upx">
                            <view class="flex-grow-1" style="font-weight:bold;" :style="item.id==shop.id?'color:#ff4544':''">
                                {{item.name}}
                            </view>
                            <view class="flex-grow-0" v-if="item.distance!=-1">{{item.distance}}</view>
                        </view>
                        <view class="flex-row" style="margin-bottom: 20upx">
                            <view class="flex-grow-1">电话：{{item.mobile}}</view>
                        </view>
                        <view>地址：{{item.address}}</view>
                    </view>
                </view>
            </scroll-view>
        </view>
        <view class="payment flex-x-center flex-y-center" v-if="data.show_payment">
            <view class="payment-modal">
                <view class="pay-modal">
                    <view class="pay-head flex-x-center flex-y-center">
                        <view>支付方式</view>
                        <view @tap="payClose" class="pay-x">
                            <image :src="data.__wxapp_img.dapp.close.url"></image>
                        </view>
                    </view>
                    <view style="border-top:1upx solid #e3e3e3" v-if="data.pay_type_list.length>0">
                        <view @tap="payPicker" class="pay-block flex-row flex-y-center" :data-index="item.payment" v-for="(item,index) in data.pay_type_list" :key="item.id">
                            <view class="flex-grow-0">
                                <image :src="item.icon" style="width:56upx;height:56upx;margin-right:32upx;"></image>
                            </view>
                            <view :class="['flex-grow-1', data.payment==item.payment?'red':'']">{{item.name}}</view>
                            <view class="flex-grow-0" v-if="data.payment==item.payment">
                                <image :src="data.__wxapp_img.dapp.pay_right.url" style="width:40upx;height:40upx;margin-right:18upx;"></image>
                            </view>
                        </view>
                    </view>
                </view>
            </view>
        </view>
				<!-- #ifdef H5 -->
				<view class="bottom-bar flex-row" v-if="data.is_area==1">
				    <view class="is_area">
				        <view>所选地区自营商品暂时无货</view>
				    </view>
				</view>
				<view class="bottom-bar flex-row" v-else>
				    <view class="flex-y-center flex-grow-1" style="padding: 0 24upx">
				        <view class="flex-grow-1" style="color:#ff4544 ">
				                总计：￥{{data.new_total_price}}
				            </view>
				    </view>
				    <view class="flex-y-center flex-grow-0 flex-x-center submit-btn" style="background-color:#ccc;" v-if="data.offer_rule&&data.offer_rule.is_allowed==1">
				        <view style="white-space:normal;">{{data.offer_rule.msg}}</view>
				    </view>
				    <view @tap="orderSubmit" class="flex-x-center flex-y-center flex-row submit-btn" v-else>
				        <view>提交</view>
				    </view>
				</view>
				<!-- #endif -->
				<!-- #ifndef H5 -->
        <cover-view class="bottom-bar flex-row" v-if="data.is_area==1">
            <cover-view class="is_area">
                <cover-view>所选地区自营商品暂时无货</cover-view>
            </cover-view>
        </cover-view>
        <cover-view class="bottom-bar flex-row" v-else>
            <cover-view class="flex-y-center flex-grow-1" style="padding: 0 24upx">
                <cover-view class="flex-grow-1" style="color:#ff4544 ">
                        总计：￥{{data.new_total_price}}
                    </cover-view>
            </cover-view>
            <cover-view class="flex-y-center flex-grow-0 flex-x-center submit-btn" style="background-color:#ccc;" v-if="data.offer_rule&&data.offer_rule.is_allowed==1">
                <cover-view style="white-space:normal;">{{data.offer_rule.msg}}</cover-view>
            </cover-view>
            <cover-view @tap="orderSubmit" class="flex-x-center flex-y-center flex-row submit-btn" v-else>
                <cover-view>提交</cover-view>
            </cover-view>
        </cover-view>
				<!-- #endif -->
				<get-card v-bind="{data:data}" @cardDel="cardDel" @cardTo="cardTo"></get-card>
			</view>
			<comp-footer v-bind="{data:data}"></comp-footer>
		</view>
	</view>
</template>

<script>var myVue = {};
	import Vue from 'vue'
	var t = "", e = "", a = Vue.prototype.getApp.helper, i = !1;
	import orderSubmitForm from '../../components/order/order-submit/form/form.vue'
	import getCard from '../../components/get-card/get-card.vue'
	export default {
		components:{orderSubmitForm,getCard},
		data() {
			return {
				data: {
        total_price: 0,
        address: null,
        express_price: 0,
        express_price_1: 0,
        integral_radio: 1,
        new_total_price: 0,
        show_card: !1,
        payment: -1,
        show_payment: !1,
        show_more: !1,
        index: -1,
        store_offline: !0
    },
			};
		},
		onLoad: function(t) {myVue = this;
        myVue.getApp.page.onLoad(this, t);
        var e = this, o = a.formatData(new Date());
        myVue.getApp.core.removeStorageSync(myVue.getApp.const.INPUT_DATA), e.setData({
            options: t,
            time: o
        }), i = !1;
				console.log(this)
    },
		onShow: function(t) {
        if (!i) {
            i = !0, myVue.getApp.page.onShow(this);
            var e = this, a = myVue.getApp.core.getStorageSync(myVue.getApp.const.PICKER_ADDRESS);
            a && e.setData({
                address: a
            }), e.getOrderData(e.data.options);
        }
    },
		onHide: function() {
        myVue.getApp.page.onHide(this), this.getInputData();
    },
    onUnload: function() {
        myVue.getApp.page.onUnload(this), myVue.getApp.core.removeStorageSync(myVue.getApp.const.INPUT_DATA);
    },
		methods: {
			bindContentInput: function(t) {
        this.data.store_list[t.currentTarget.dataset.index].content = t.detail.value, this.setData({
            store_list: this.data.store_list
        });
    },
    KeyName: function(t) {
        var e = this.data.store_list;
        e[t.currentTarget.dataset.index].offline_name = t.detail.value, this.setData({
            store_list: e
        });
    },
    KeyMobile: function(t) {
        var e = this.data.store_list;
        e[t.currentTarget.dataset.index].offline_mobile = t.detail.value, this.setData({
            store_list: e
        });
    },
    getOffline: function(t) {
        var e = this, a = t.currentTarget.dataset.offline, i = t.currentTarget.dataset.index, o = e.data.store_list;
        o[i].offline = a, e.setData({
            store_list: o
        }), 1 == o.length && 0 == o[0].store_id && 1 == o[0].offline ? e.setData({
            store_offline: !1
        }) : e.setData({
            store_offline: !0
        }), e.getPrice();
    },
    dingwei: function() {
        var a = this;
        myVue.getApp.getauth({
            content: "需要获取您的地理位置授权，请到小程序设置中打开授权",
            author: "scope.userLocation",
            success: function(i) {
                i && (i.authSetting["scope.userLocation"] ? myVue.getApp.core.chooseLocation({
                    success: function(i) {
                        t = i.longitude, e = i.latitude, a.setData({
                            location: i.address
                        }), a.getOrderData(a.data.options);
                    }
                }) : myVue.getApp.core.showToast({
                    title: "您取消了授权",
                    image: "/static/images/icon-warning.png"
                }));
            }
        });
    },
    orderSubmit: function(t) {
        var e = this, a = {}, i = e.data.store_list;
        for (var o in i) {
            var s = i[o].form;
            if (s && 1 == s.is_form && 0 == i[o].store_id) {
                var n = s.list;
                for (var r in n) if (1 == n[r].required) if ("radio" == n[r].type || "checkbox" == n[r].type) {
                    var c = !1;
                    for (var p in n[r].default_list) 1 == n[r].default_list[p].is_selected && (c = !0);
                    if (!c) return myVue.getApp.core.showModal({
                        title: "提示",
                        content: "请填写" + s.name + "，加‘*’为必填项",
                        showCancel: !1
                    }), !1;
                } else if (!n[r].default || void 0 == n[r].default) return myVue.getApp.core.showModal({
                    title: "提示",
                    content: "请填写" + s.name + "，加‘*’为必填项",
                    showCancel: !1
                }), !1;
            }
            if (1 == i.length && 0 == i[o].store_id && 1 == i[o].offline) ; else {
                if (!e.data.address) return myVue.getApp.core.showModal({
                    title: "提示",
                    content: "请选择收货地址",
                    showCancel: !1
                }), !1;
                a.address_id = e.data.address.id;
            }
        }
        if (a.store_list = JSON.stringify(i), e.data.pond_id > 0) {
            if (e.data.express_price > 0 && -1 == e.data.payment) return e.setData({
                show_payment: !0
            }), !1;
        } else if (-1 == e.data.payment) return e.setData({
            show_payment: !0
        }), !1;
        1 == e.data.integral_radio ? a.use_integral = 1 : a.use_integral = 2, a.payment = e.data.payment, 
        a.formId = t.detail.formId, e.order_submit(a, "s");
    },
		getOrderData: function(a) {
        var i = this, o = {}, s = "";
        i.data.address && i.data.address.id && (s = i.data.address.id), o.address_id = s, 
        o.longitude = t, o.latitude = e, myVue.getApp.core.showLoading({
            title: "正在加载",
            mask: !0
        }), o.store_list = a.store_list, myVue.getApp.request({
            url: myVue.getApp.api.order.new_submit_preview,
            method: "POST",
            data: o,
            success: function(t) {
                if (i.getApp.core.hideLoading(), 0 == t.code) {
                    var e = i.getApp.core.getStorageSync(i.getApp.const.INPUT_DATA), a = t.data, o = -1, s = 1, n = a.store_list, r = [];
                    e && (r = e.store_list, o = e.payment, s = e.integral_radio), a.integral_radio = s;
                    for (var c in a.pay_type_list) {
                        if (o == a.pay_type_list[c].payment) {
                            a.payment = o;
                            break;
                        }
                        if (1 == a.pay_type_list.length) {
                            a.payment = a.pay_type_list[c].payment;
                            break;
                        }
                    }
                    for (var c in n) {
                        var p = {}, d = {};
                        if (n[c].show = !1, n[c].show_length = n[c].goods_list.length - 1, 0 != r.length) for (var l in r) n[c].store_id == r[l].store_id && (n[c].content = r[l].content, 
                        n[c].form = r[l].form, p = r[l].shop, d = r[l].picker_coupon, n[c].offline_name = r[l].offline_name, 
                        n[c].offline_mobile = r[l].offline_mobile);
                        for (var l in n[c].shop_list) {
                            if (p && p.id == n[c].shop_list[l].id) {
                                n[c].shop = p;
                                break;
                            }
                            if (1 == n[c].shop_list.length) {
                                n[c].shop = n[c].shop_list[l];
                                break;
                            }
                            if (1 == n[c].shop_list[l].is_default) {
                                n[c].shop = n[c].shop_list[l];
                                break;
                            }
                        }
                        if (d) for (var l in n[c].coupon_list) if (d.id == n[c].coupon_list[l].id) {
                            n[c].picker_coupon = d;
                            break;
                        }
                        n[c].send_type && 2 == n[c].send_type ? (n[c].offline = 1, i.setData({
                            store_offline: !1
                        })) : n[c].offline = 0;
                    }
                    a.store_list = n;
                    var _ = i.data.index;
                    -1 != _ && n[_].shop_list && n[_].shop_list.length > 0 && i.setData({
                        show_shop: !0,
                        shop_list: n[_].shop_list
                    }), i.setData(a), i.getPrice();
                }
                1 == t.code && i.getApp.core.showModal({
                    title: "提示",
                    content: t.msg,
                    showCancel: !1,
                    confirmText: "返回",
                    success: function(t) {
                        t.confirm && i.getApp.core.navigateBack({
                            delta: 1
                        });
                    }
                });
            }
        });
    },
    showCouponPicker: function(t) {
        var e = this, a = t.currentTarget.dataset.index, i = e.data.store_list;
        e.getInputData(), i[a].coupon_list && i[a].coupon_list.length > 0 && e.setData({
            show_coupon_picker: !0,
            coupon_list: i[a].coupon_list,
            index: a
        });
    },
    pickCoupon: function(t) {
        var e = this, a = t.currentTarget.dataset.index, i = e.data.index, o = myVue.getApp.core.getStorageSync(myVue.getApp.const.INPUT_DATA);
        myVue.getApp.core.removeStorageSync(myVue.getApp.const.INPUT_DATA);
        var s = o.store_list;
        "-1" == a || -1 == a ? (s[i].picker_coupon = !1, o.show_coupon_picker = !1) : (s[i].picker_coupon = e.data.coupon_list[a], 
        o.show_coupon_picker = !1), o.store_list = s, o.index = -1, e.setData(o), e.getPrice();
    },
    showShop: function(t) {
        var e = this, a = t.currentTarget.dataset.index;
        e.getInputData(), e.setData({
            index: a
        }), e.dingwei();
    },
    pickShop: function(t) {
        var e = this, a = t.currentTarget.dataset.index, i = e.data.index, o = myVue.getApp.core.getStorageSync(myVue.getApp.const.INPUT_DATA), s = o.store_list;
        "-1" == a || -1 == a ? (s[i].shop = !1, o.show_shop = !1) : (s[i].shop = e.data.shop_list[a], 
        o.show_shop = !1), o.store_list = s, o.index = -1, e.setData(o), e.getPrice();
    },
    integralSwitchChange: function(t) {
        var e = this;
        0 != t.detail.value ? e.setData({
            integral_radio: 1
        }) : e.setData({
            integral_radio: 2
        }), e.getPrice();
    },
    integration: function(t) {
        var e = this.data.integral.integration;
        myVue.getApp.core.showModal({
            title: "积分使用规则",
            content: e,
            showCancel: !1,
            confirmText: "我知道了",
            confirmColor: "#ff4544",
            success: function(t) {
                t.confirm;
            }
        });
    },
    contains: function(t, e) {
        for (var a = t.length; a--; ) if (t[a] == e) return a;
        return -1;
    },
    getPrice: function() {
        var t = this, e = t.data.store_list, a = t.data.integral_radio, i = (t.data.integral, 
        0), o = 0, s = {}, n = 0;
        for (var r in e) {
            var c = e[r], p = (parseFloat(c.total_price), parseFloat(c.level_price)), d = e[r].goods_list;
            n = 0, c.picker_coupon && c.picker_coupon.sub_price > 0 && (1 == c.picker_coupon.appoint_type && null != c.picker_coupon.cat_id_list ? d.forEach(function(e, a, i) {
                for (var o in e.cat_id) -1 != t.contains(c.picker_coupon.cat_id_list, e.cat_id[o]) && (n += parseFloat(e.price));
            }) : 2 == c.picker_coupon.appoint_type && null != c.picker_coupon.goods_id_list && d.forEach(function(e, a, i) {
                -1 != t.contains(c.picker_coupon.goods_id_list, e.goods_id) && (n += parseFloat(e.price));
            }), c.picker_coupon.sub_price > n && n > 0 ? p -= parseFloat(n) : p -= c.picker_coupon.sub_price), 
            c.integral && c.integral.forehead > 0 && 1 == a && (p -= parseFloat(c.integral.forehead)), 
            0 == c.offline && (c.express_price && (p += c.express_price), c.offer_rule && 1 == c.offer_rule.is_allowed && (s = c.offer_rule), 
            1 == c.is_area && (o = 1)), i += parseFloat(p);
        }
        i = i >= 0 ? i : 0, t.setData({
            new_total_price: i.toFixed(2),
            offer_rule: s,
            is_area: o
        });
    },
    cardDel: function() {
        this.setData({
            show_card: !1
        }), myVue.getApp.core.redirectTo({
            url: "/pages/order/order?status=1"
        });
    },
    cardTo: function() {
        this.setData({
            show_card: !1
        }), myVue.getApp.core.redirectTo({
            url: "/pages/card/card"
        });
    },
    formInput: function(t) {
        var e = this, a = t.currentTarget.dataset.index, i = t.currentTarget.dataset.formId, o = e.data.store_list, s = o[a].form, n = s.list;
        n[i].default = t.detail.value, s.list = n, e.setData({
            store_list: o
        });
    },
    selectForm: function(t) {
        var e = this, a = e.data.store_list, i = t.currentTarget.dataset.index, o = t.currentTarget.dataset.formId, s = t.currentTarget.dataset.k, n = a[i].form, r = n.list, c = r[o].default_list;
        if ("radio" == r[o].type) {
            for (var p in c) p == s ? c[s].is_selected = 1 : c[p].is_selected = 0;
            r[o].default_list = c;
        }
        "checkbox" == r[o].type && (1 == c[s].is_selected ? c[s].is_selected = 0 : c[s].is_selected = 1, 
        r[o].default_list = c), n.list = r, a[i].form = n, e.setData({
            store_list: a
        });
    },
    showPayment: function() {
        this.setData({
            show_payment: !0
        });
    },
    payPicker: function(t) {
        var e = t.currentTarget.dataset.index;
        this.setData({
            payment: e,
            show_payment: !1
        });
    },
    payClose: function() {
        this.setData({
            show_payment: !1
        });
    },
    getInputData: function() {
        var t = this, e = t.data.store_list, a = {
            integral_radio: t.data.integral_radio,
            payment: t.data.payment,
            store_list: e
        };
        myVue.getApp.core.setStorageSync(myVue.getApp.const.INPUT_DATA, a);
    },
		uploadImg: function(t) {
        var e = this, a = t.currentTarget.dataset.index, o = t.currentTarget.dataset.formId, s = e.data.store_list, n = s[a].form;
        i = !0, myVue.getApp.uploader.upload({
            start: function() {
                myVue.getApp.core.showLoading({
                    title: "正在上传",
                    mask: !0
                });
            },
            success: function(t) {
                0 == t.code ? (n.list[o].default = t.data.url, e.setData({
                    store_list: s
                })) : e.showToast({
                    title: t.msg
                });
            },
            error: function(t) {
                e.showToast({
                    title: t
                });
            },
            complete: function() {
                myVue.getApp.core.hideLoading();
            }
        });
    },
    goToAddress: function() {
        i = !1, myVue.getApp.core.navigateTo({
            url: "/pages/address-picker/address-picker"
        });
    },
    showMore: function(t) {
        var e = this, a = e.data.store_list, i = t.currentTarget.dataset.index;
        a[i].show = !a[i].show, e.setData({
            store_list: a
        });
    }
		},
	}
</script>

<style scoped>

.bottom-bar {
    position: fixed;
    bottom: var(--window-bottom);
    left: 0;
    height: 120upx;
    background: #fff;
    border-top: 1upx solid #e3e3e3;
    width: 100%;
    z-index: 1000;
}

.bottom-bar .submit-btn {
    background-color: #ff4544;
    color: #fff;
    width: 270upx;
    text-align: center;
    margin: 0;
    padding: 0 20upx;
    border-radius: 0;
    height: 100%;
}

.address-picker {
    background: #fff;
    padding: 34upx 24upx;
}

.cart-checkbox {
    display: inline-block;
    width: 40upx;
    height: 40upx;
    background-size: 100% 100%;
    background-image: url();
}

.cart-checkbox.active {
    background-image: url();
}

.cart-item {
    background: #fff;
    padding: 32upx 24upx 10upx 24upx;
}

.cart-item .goods-pic {
    width: 156upx;
    height: 156upx;
    margin-right: 20upx;
}

.cart-item .goods-name {
    margin-bottom: 10upx;
    -webkit-line-clamp: 2;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.cart-item .attr-list,.cart-item .num {
    font-size: 9pt;
    color: #888;
}

.cart-item .attr-list .attr-item {
    display: inline-block;
    margin-right: 36upx;
}

.cart-item .attr-list .attr-item:last-child {
    margin-right: 0;
}

.cart-item .price {
    color: #ff4544;
}

.coupon-picker {
    position: fixed;
    top: var(--window-top);
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1001;
    background: #fff;
    border-top: 1upx solid #e3e3e3;
}

.coupon-list {
    padding: 34upx;
}

.coupon-list .coupon-item {
    height: 152upx;
    width: 682upx;
    position: relative;
    margin-bottom: 24upx;
}

.coupon-list .coupon-item.coupon-status-1 .coupon-right,.coupon-list .coupon-item.coupon-status-2 .coupon-right {
    color: rgba(0,0,0,0.35)!important;
}

.coupon-list .coupon-item .coupon-bg {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    z-index: -1;
}

.coupon-list .coupon-item .coupon-status-icon {
    width: 140upx;
    height: 98upx;
    position: absolute;
    top: 0;
    right: 8upx;
    z-index: 1;
}

.coupon-list .coupon-item .coupon-left {
    color: #fff;
    width: 202upx;
}

.coupon-list .coupon-item .coupon-right {
    padding: 20upx 10upx;
}

.shop-block {
    width: 100%;
    height: 70upx;
    padding-left: 24upx;
}

.shop-address {
    width: 100%;
    background-color: #fff;
    padding: 30upx 24upx;
}

.goods-intrgral {
    height: 60upx;
    background-color: #fff7f6;
    width: 100%;
    border-bottom: 1upx solid #e3e3e3;
    color: #919191;
    font-size: 9pt;
    padding: 0 24upx;
}

.integral-switch .wx-switch-input {
    width: 42px;
    height: 22px;
}

.integral-switch .wx-switch-input::before {
    width: 41px;
    height: 20px;
}

.integral-switch .wx-switch-input::after {
    width: 20px;
    height: 20px;
}

.page /deep/ .form-title {
    width: 100%;
    height: 72upx;
    line-height: 72upx;
    border-bottom: 1upx #e3e3e3 solid;
    color: #707070;
}

.page /deep/ .form-one {
    padding: 24upx 0;
    border-bottom: 1upx #e3e3e3 solid;
}

.page /deep/ .form-one:last-child {
    margin: 0;
    border: 0;
}

.page /deep/ .required::before {
    content: '*';
    color: #ff4544;
}

.page /deep/ .form-one .list-name {
    width: 170upx;
    justify-content: flex-end;
    text-align: right;
    margin-right: 20upx;
}

.page /deep/ .default {
    height: 56prx;
    padding: 12upx 24upx;
    margin-right: 20upx;
    border-radius: 56upx;
    border: 1upx #ccc solid;
    color: #666;
    margin-bottom: 10upx;
}

.page /deep/ .default:last-child {
    margin-right: 0;
}

.page /deep/ .d-active {
    background-color: #ff4544;
    color: #fff;
    border: 1upx #ff4544 solid;
}

.page /deep/ .right-jiantou {
    width: 12upx;
    height: 22upx;
    margin-left: 12upx;
}

.payment {
    width: 100%;
    height: 100%;
    position: fixed;
    left: 0;
    bottom: var(--window-bottom);
    z-index: 9999;
    background-color: rgba(0,0,0,0.5);
}

.payment-modal {
    position: relative;
    width: 100%;
    padding: 0 60upx;
}

.pay-modal {
    width: 100%;
    background-color: #fff;
    border-radius: 16upx;
}

.pay-head {
    height: 112upx;
    width: 100%;
    color: #353535;
    position: relative;
}

.pay-x {
    position: absolute;
    right: 40upx;
    top: 40upx;
    width: 36upx;
    height: 36upx;
}

.pay-x image {
    width: 100%;
    height: 100%;
}

.pay-block {
    width: 100%;
    height: 120upx;
    color: #999;
    padding: 0 30upx;
}

.red {
    color: #ff4544;
}

.pay-footer {
    width: 100%;
    height: 88upx;
    background-color: #ff4544;
    color: #fff;
}

.store-header {
    background: #fff;
    padding: 24upx;
    border-bottom: 1upx solid #eee;
}

.border-bottom {
    position: relative;
}

.border-bottom:after {
    content: " ";
    display: block;
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 0;
    border-bottom: 1upx solid #eee;
}

.store-item {
    margin-bottom: 24upx;
}

.is_area {
    background: #febd14;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

.check-icon {
    width: 38upx;
    height: 38upx;
    border: 4upx solid #ccc;
    border-radius: 1000upx;
    position: relative;
    margin-right: 4upx;
}

.check-icon::after {
    position: absolute;
    content: " ";
    display: block;
    width: 30upx;
    height: 30upx;
    top: 4upx;
    left: 4upx;
    background: #e3e3e3;
    border-radius: 1000upx;
}

.send-type {
    width: 160upx;
    border: 1upx solid #3f3f3f;
    color: #3f3f3f;
    border-radius: 8upx;
    margin-left: 20upx;
    padding: 6upx 0;
}

.send-type:first-child {
    margin-left: 0;
}

.send-type.active {
    border: 1upx solid #ff4544;
    color: #ff4544;
}

.address-bg-img {
    width: 100%;
    height: 8upx;
}

.address-bg-img image {
    width: 100%;
    height: 100%;
}

.block {
    border-top: 1upx solid #e3e3e3;
    margin-bottom: 20upx;
    background: #fff;
}

.show-more {
    height: 72upx;
    color: #919191;
    background: #fff;
}

.show-more-img {
    width: 18upx;
    height: 18upx;
    margin-left: 16upx;
}

.cart-list {
    margin-bottom: 20upx;
}
</style>
